473,468 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Loading HTMLDocument from a string

Hello All,

I have an HTML document stored in a database field and wish to load
and manipulate it with inline C# code like the following:

WebBrowser webControl = new WebBrowser();
webControl.DocumentText = htmlstringfromdb;
//Need to wait for DocumentCompleted event to be sure page is loaded.
HtmlDocument doc = webControl.Document;
string test = doc.Body.ToString();

The problem is that as indicated in the comment line above, it appears
if you try to set the DocumentText property of the WebBrowser control
with HTML, you need to wait for the DocumentCompleted event to be sure
it's loaded before trying to access the elements.

Does anyone know any way to wait for the document to load inline?

-Frank

Feb 26 '07 #1
1 43138
On Feb 25, 9:03 pm, "Frank Perugini" <perug...@yahoo.comwrote:
Hello All,

I have an HTML document stored in a database field and wish to load
and manipulate it with inline C# code like the following:

WebBrowser webControl = new WebBrowser();
webControl.DocumentText = htmlstringfromdb;
//Need to wait for DocumentCompleted event to be sure page is loaded.
HtmlDocument doc = webControl.Document;
string test = doc.Body.ToString();

The problem is that as indicated in the comment line above, it appears
if you try to set the DocumentText property of the WebBrowser control
with HTML, you need to wait for the DocumentCompleted event to be sure
it's loaded before trying to access the elements.

Does anyone know any way to wait for the document to load inline?

-Frank
I found it myself. For others interested:

WebBrowser webControl = new WebBrowser();
webControl.DocumentText = htmlstringfromdb;

do
{
Application.DoEvents();
} while (webControl.ReadyState != WebBrowserReadyState.Complete);

string test = webControl.Document.Body.InnerHtml;

-Frank

Feb 26 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Cristian | last post by:
>-----Original Message----- >What is the best method of loading a string (which >contains an xml file) into a Data Set--without writing it >to disk? > >. >Thank you for the reply.
4
by: Allan Bruce | last post by:
I want to load config from a file. I know how to load in numbers using an ifstream, but I cant get it to load a string. Can somebody tell me how to load a string from file? Here is my code: ...
1
by: mr_burns | last post by:
Hi, i was wondering if it is possible to load text into a string from an external text file. the reason is that i have a very large string and it is making my script very messy. also, is it...
0
by: Lady_A | last post by:
Hi, I have an XP SP2, .net framework 1.1 SP1. An html/css interface using jscripts in which I create ActiveX objects and present a dialog using the appropriate language set by the user on that...
7
by: mike | last post by:
I have a number of sources of javascript and don't really know the sequence of when each gets loaded. <SCRIPT FOR="window" EVENT="onLoad"> var tmp = "where are you"; </script> <script...
2
by: acool | last post by:
I am passing in, as a parameter, a string of XML, and want to formulate a new XML docuent but i am getting errors. I tried this: public string makeDoc(string document) { // XmlDocument doc =...
3
by: Joe | last post by:
Hi, I have a simple thing I need to do but just doesn't work in VB.NET. I have a string with HTML code and I want to load it into a HTMLDocument object or something similiar to it so I can...
6
by: Shigun | last post by:
On a website I am working on I am trying to load another page into a div on the the page the user does his work from. What I have works correctly in FireFox, but not in IE. I've rummaged Google for...
1
by: gdarian216 | last post by:
Okay I am writting a program that will take input from a file and store it in a string. Then the string is separated at the whitespaces and these separate strings are loaded in a vector. My problem...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.